/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;

import java.util.ArrayList;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Sergio
 */
public class TabelaQuarto extends AbstractTableModel{

    protected Vector dataVector;
    
    private ArrayList<Quarto> Quartos = new ArrayList<Quarto>();
    private String[] colunas = {"Código","Andar", "Qtd. Leitos"};
    
    public static final int INDICE_CODIGO = 0;
    public static final int INDICE_ANDAR = 1;
    public static final int INDICE_QTDLEITOS = 2;

    
    @Override
    public int getRowCount() {
        return Quartos.size();
    }

    @Override
    public int getColumnCount() {
        return colunas.length;
    }
    @Override
    public String getColumnName(int coluna) {
        return colunas[coluna];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        String[] linha = Quartos.get(rowIndex).toArray();
        return linha[columnIndex];
    }
    public void addQuarto(Quarto Quarto) {
        Quartos.add(Quarto);
        this.fireTableDataChanged();
    }

    public Quarto getSelectedQuarto(int linhaSelecionada) {
        return Quartos.get(linhaSelecionada);
    }
    
    public void removeQuarto(int linhaSelecionada){
        Quartos.remove(linhaSelecionada);
        this.fireTableDataChanged();
    }
    
    public void limpaArray(){
        Quartos.clear();
    }
 
}
